﻿namespace ExtensionMethods.Test.Extensions
{
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Groundwork.Extensions;
    using FluentAssertions;
    using System.Collections.Generic;

    [TestClass]
    public class ObjectTests
    {
        /// <summary>
        /// Tests if the object will throw a null exception.
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ObjectNullThrowsException()
        {
            object testing = null;
            testing.ThrowIfNull();
        }

        /// <summary>
        /// Tests if a null reference exception is raised if generic parameter is specified.
        /// </summary>
        [TestMethod]
        public void ObjectNullThrowsNullReferenceException()
        {
            try
            {
                object testing = null;
                testing.ThrowIfNull();
            }
            catch (Exception exception)
            {
                exception.Should().BeOfType<ArgumentException>();
            }
        }

        /// <summary>
        /// Tests if an exception is raised when a valid string is provided.
        /// </summary>
        [TestMethod]
        public void ObjectNotNullThrowsNullReferenceException()
        {
            object testing = "hello world";
            testing.ThrowIfNull();
            testing.Should().BeOfType<string>();
            testing.Should().Be("hello world");
        }

        [TestMethod]
        public void ObjectArraySwithTest()
        {
            Dictionary<string, Action<object[]>> proc = new Dictionary<string, Action<object[]>>()
            {
                {"key1", ProcessingItem1},
                {"key2", ProcessingItem2}
            };

            string testing = "key1";
            testing.Switch<string>(proc, "value1");
        }

        private void ProcessingItem1(params object[] args)
        {
            string value = (string)args[0]; 
        }

        private void ProcessingItem2(params object[] args)
        {
            string value = (string)args[0]; 
        }

  

    }
}
